Learning iPhone Programming by Alasdair Allan
Author:Alasdair Allan [Alasdair Allan]
Language: eng
Format: epub
Tags: COMPUTERS / Hardware / Personal Computers / Macintosh
ISBN: 9781449382865
Publisher: O'Reilly Media
Published: 2010-03-02T16:00:00+00:00
Populating the UI
Now that we’ve populated the data model, let’s create the updateView: method in our view controller. This is where we take the data that we just parsed from the XML and push it into the current view. Replace the updateView: method in MainViewController.m with the following:
- (void)updateView { // City Info nameLabel.text = forecast.location; dateLabel.text = forecast.date; // Now nowTempLabel.text = forecast.temp; nowHumidityLabel.text = forecast.humidity; nowWindLabel.text = forecast.wind; nowConditionLabel.text = forecast.condition; NSURL *url = [NSURL URLWithString:(NSString *)forecast.icon]; NSData *data = [NSData dataWithContentsOfURL:url]; nowImage.image = [[UIImage alloc] initWithData:data]; // Day 1 dayOneLabel.text = [forecast.days objectAtIndex:0]; dayOneTempLabel.text = [forecast.temps objectAtIndex:0]; dayOneChanceLabel.text = [forecast.conditions objectAtIndex:0]; url = [NSURL URLWithString:(NSString *)[forecast.icons objectAtIndex:0]]; data = [NSData dataWithContentsOfURL:url]; dayOneImage.image = [[UIImage alloc] initWithData:data]; // Day 2 dayTwoLabel.text = [forecast.days objectAtIndex:1]; dayTwoTempLabel.text = [forecast.temps objectAtIndex:1]; dayTwoChanceLabel.text = [forecast.conditions objectAtIndex:1]; url = [NSURL URLWithString:(NSString *)[forecast.icons objectAtIndex:1]]; data = [NSData dataWithContentsOfURL:url]; dayTwoImage.image = [[UIImage alloc] initWithData:data]; // Day 3 dayThreeLabel.text = [forecast.days objectAtIndex:2]; dayThreeTempLabel.text = [forecast.temps objectAtIndex:2]; dayThreeChanceLabel.text = [forecast.conditions objectAtIndex:2]; url = [NSURL URLWithString:(NSString *)[forecast.icons objectAtIndex:2]]; data = [NSData dataWithContentsOfURL:url]; dayThreeImage.image = [[UIImage alloc] initWithData:data]; // Day 4 dayFourLabel.text = [forecast.days objectAtIndex:3]; dayFourTempLabel.text = [forecast.temps objectAtIndex:3]; dayFourChanceLabel.text = [forecast.conditions objectAtIndex:3]; url = [NSURL URLWithString:(NSString *)[forecast.icons objectAtIndex:3]]; data = [NSData dataWithContentsOfURL:url]; dayFourImage.image = [[UIImage alloc] initWithData:data]; [loadingActivityIndicator stopAnimating]; }
We’re done. Click the Build and Run button on the Xcode toolbar to build and start the application in iPhone Simulator.
Once the application starts up, if all goes well you should get something that looks similar to Figure 7-15. There is, after all, almost always a chance of rain in London.
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Embedded Programming with Modern C++ Cookbook by Igor Viarheichyk(4047)
Linux Device Driver Development Cookbook by Rodolfo Giometti(4011)
Implementing Cellular IoT Solutions for Digital Transformation by Dennis McCain(3969)
Embedded Linux Development Using Yocto Project - Third Edition by Otavio Salvador & Daiane Angolini(3831)
TinyML Cookbook by Gian Marco Iodice(3725)
Simplifying 3D Printing with OpenSCAD by Colin Dow(2892)
TinyML Cookbook by Gian Marco Iodice & Ronan Naughton(2651)
Fusion 360 for Makers by Lydia Sloan Cline(2296)
Networking A Beginner's Guide by Bruce Hallberg(2276)
Hands-On Linux for Architects by Denis Salamanca(2120)
Computers For Seniors For Dummies by Nancy C. Muir(2096)
But How Do It Know? by J. Clark Scott(2069)
Raspberry Pi and MQTT Essentials by Dhairya Parikh(2022)
Arduino Project Handbook, Volume 2: 25 Simple Electronics Projects for Beginners by Geddes Mark(1988)
9781803246888-ENHANCING DEEP LEARNING WITH BAYESIAN INFERENCE by Unknown(1957)
Hack and HHVM by Owen Yamauchi(1941)
31 Days Before Your CompTIA A+ Exams (Shanette Luellen's Library) by Benjamin Patrick Conry(1910)
Hands-On Internet of Things with MQTT by Tim Pulver(1814)
MicroPython Projects by Jacob Beningo(1807)